<?php
/**
 * 首页显示
 * @author caoge
 * @version 2012-5-7
 */
class IndexAction extends BaseAction{
	public function __construct(){
		parent::__construct();
		$this->assign('hover','index');
	}
	
	public function index(){
		$Article = D(Article);
		$list = $Article->where('del_flag=0')->limit(11)->field('article_id,title,create_time')->order('create_time desc')->select();
		foreach ($list as &$v){
			$v['create_time'] = date("Y/m/d",strtotime($v['create_time']));
		}
		$recommendList = $Article->where('del_flag=0 AND is_recommend=1')->limit(11)->field('article_id,title,create_time')->order('sort desc')->select();
		foreach ($recommendList as &$v){
			$v['create_time'] = date("Y/m/d",strtotime($v['create_time']));
		}
		load('extend'); //截取标题字符串
		$this->assign('list',$list);
		$this->assign('headTitle','首页');
		$this->assign('recommendList',$recommendList);
		$this->getSideBar();
		$this->display();
	}
	
	/**
	 * 获取侧栏
	 * 
	 * @author caoge
	 * @version 2012-5-27
	 */
	public function getSideBar(){
		$ArticleType = D(ArticleType);
		$typeList = $ArticleType->getTypeList();
		$this->assign('typeList',$typeList);
	}
}